import makerjs from "makerjs"
import { getPointer } from "./getPointer"

const Rectangle = {
    wheel: function (e, _this) {
        var scale = _this.viewScale + e.deltaY / 1000;
        _this.viewScale = Math.max(scale, 0.01)
    },
    pointermove: function (e, _this) {
        if (e.pressure) {
            var end_point = getPointer(e, _this);
            var vector = makerjs.point.subtract(
                end_point,
                _this.last_pointer_down
            );
            var rect = new makerjs.models.Rectangle(vector[0], vector[1]);
            rect.origin = _this.last_pointer_down;
            _this.$set(_this.model.models, "rect" + _this.layer, rect);
        }
    },
    pointerdown: function (e, _this) {
        _this.last_pointer_down = getPointer(e, _this);
    },
    pointerup: function (e, _this) {
        _this.layer++;
    },
}
export default Rectangle;
